import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '项目',
    align: "center",
    dataIndex: 'projectId_dictText'
  },
  {
    title: '系统',
    align: "center",
    dataIndex: 'projectSystemId_dictText'
  },
  {
    title: '批次名称',
    align: "center",
    dataIndex: 'batchName_dictText'
  },
  {
    title: '计划投产日期',
    align: "center",
    dataIndex: 'planProductTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '轮次名称',
    align: "center",
    dataIndex: 'testRoundName'
  },
  {
    title: '轮次属性',
    align: "center",
    dataIndex: 'testRoundType_dictText'
  },
  {
    title: '轮次类型',
    align: "center",
    dataIndex: 'testRoundAttr_dictText'
  },
  {
    title: '计划开始日期',
    align: "center",
    dataIndex: 'planStart',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '计划结束日期',
    align: "center",
    dataIndex: 'planEnd',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '测试环境',
    align: "center",
    dataIndex: 'testEnv'
  },
  {
    title: '描述',
    align: "center",
    dataIndex: 'description'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "项目",
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "系统",
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "批次名称",
    field: 'batchName',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_batch,batch_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "计划投产日期",
    field: 'planProductTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "轮次名称",
    field: 'testRoundName',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "轮次属性",
    field: 'testRoundType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_test_stage,test_stage_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "轮次类型",
    field: 'testRoundAttr',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_test_stage_type,stage_type_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "计划开始日期",
    field: 'planStart',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "计划结束日期",
    field: 'planEnd',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "测试环境",
    field: 'testEnv',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "描述",
    field: 'description',
    component: 'Input',
    //colProps: {span: 6},
  },
  {
    label: "创建人",
    field: 'createBy',
    component: 'Input',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '项目',
    field: 'projectId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '系统',
    field: 'projectSystemId',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_system,system_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入系统!'},
             ];
    },
  },
  {
    label: '批次名称',
    field: 'batchName',
    component: 'JSearchSelect',
    componentProps:{
      dict: "tm_project_batch,batch_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入批次名称!'},
             ];
    },
  },
  {
    label: '计划投产日期',
    field: 'planProductTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入计划投产日期!'},
             ];
    },
  },
  {
    label: '轮次名称',
    field: 'testRoundName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入轮次名称!'},
             ];
    },
  },
  {
    label: '轮次属性',
    field: 'testRoundType',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_test_stage,test_stage_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入轮次属性!'},
             ];
    },
  },
  {
    label: '轮次类型',
    field: 'testRoundAttr',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_test_stage_type,stage_type_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入轮次类型!'},
             ];
    },
  },
  {
    label: '计划开始日期',
    field: 'planStart',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入计划开始日期!'},
             ];
    },
  },
  {
    label: '计划结束日期',
    field: 'planEnd',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入计划结束日期!'},
             ];
    },
  },
  {
    label: '测试环境',
    field: 'testEnv',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入测试环境!'},
             ];
    },
  },
  {
    label: '描述',
    field: 'description',
    component: 'InputTextArea',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  projectId: {title: '项目',order: 0,view: 'sel_search', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  projectSystemId: {title: '系统',order: 1,view: 'sel_search', type: 'string',dictTable: "tm_project_system", dictCode: 'id', dictText: 'system_name',},
  batchName: {title: '批次名称',order: 2,view: 'sel_search', type: 'string',dictTable: "tm_project_batch", dictCode: 'id', dictText: 'batch_name',},
  planProductTime: {title: '计划投产日期',order: 3,view: 'date', type: 'string',},
  testRoundName: {title: '轮次名称',order: 4,view: 'text', type: 'string',},
  testRoundType: {title: '轮次属性',order: 5,view: 'list', type: 'string',dictTable: "tm_test_stage", dictCode: 'id', dictText: 'test_stage_name',},
  testRoundAttr: {title: '轮次类型',order: 6,view: 'list', type: 'string',dictTable: "tm_test_stage_type", dictCode: 'id', dictText: 'stage_type_name',},
  planStart: {title: '计划开始日期',order: 7,view: 'date', type: 'string',},
  planEnd: {title: '计划结束日期',order: 8,view: 'date', type: 'string',},
  testEnv: {title: '测试环境',order: 9,view: 'textarea', type: 'string',},
  description: {title: '描述',order: 10,view: 'textarea', type: 'string',},
  createBy: {title: '创建人',order: 11,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 12,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 13,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 14,view: 'datetime', type: 'string',},
};
